#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef pair<int,int> PII; 

const int N=300010;
int a[N],s[N];

vector<int> alls;
vector<PII> add,query;

int find(int x)
{
    int l=0,r=alls.size()-1;
    while(l<r)
    {
        int mid=(l+r)>>1;
        if(alls[mid]>=x) r=mid;
        else l=mid+1;
    }
    return r+1;
}

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;++i)
    {
        int x,c;
        scanf("%d %d",&x,&c);
        add.emplace_back(x,c);
        
        alls.emplace_back(x);
    }
    
    for(int i=0;i<m;++i)
    {
        int l,r;
        scanf("%d %d",&l,&r);
        query.emplace_back(l,r);
        
        alls.emplace_back(l);
        alls.emplace_back(r);
    }
    sort(alls.begin(),alls.end());
    alls.erase(unique(alls.begin(),alls.end()),alls.end());
    for(auto e:add)
    {
        int x=find(e.first);
        a[x]+=e.second;
    }
    
    for(int i=1;i<=alls.size();++i) s[i]=s[i-1]+a[i];
    
    for(auto q: query)
    {
        int l=find(q.first),r=find(q.second);
        cout<<s[r]-s[l-1]<<endl;
    }
    return 0;
}